﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Management;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ConsoleApplication4
{

    class Program
    {

            [STAThread]
        static void Main(string[] args)
        {
            if (args.Length > 1)
            {
                string ServerName = args[0];

                if (args[1] == "CPU")
                {

                 wmi.PerformanceMonitor(ServerName, "henry.jartu", "hms123#");
                   
                }

                if (args[1] == "IISRESET")
                {
                    wmi.IISReset(ServerName);
                }

                if (args[1] == "OFFLINE")
                {
                    wmi.ServerOffline(ServerName);
                }

                if (args[1] == "ONLINE")
                {
                    wmi.ServerOnline(ServerName);
                }

                if (args[1] == "EXPORTREG")
                {
                    wmi.ExportReg("HKEY_LOCAL_MACHINE\\Software\\RCI", "C:\\myLocal.reg", ServerName);
                }               
                
            }

            else
            {
                print_help();
            }

      
        }

        static void print_help()
        {
            Console.WriteLine("LineServerMonitorTool [ServerName] [Command]");
            Console.WriteLine("");
            Console.WriteLine("Here is a list of valid commands for this tool:");
            Console.WriteLine("      CPU = Will show the processor utlization.");
            Console.WriteLine(" IISRESET = The will allow the IIS to be reset.");
            Console.WriteLine("  OFFLINE = Will take the server offline");
            Console.WriteLine("   ONLINE = This will bring the server back on");
            Console.WriteLine("EXPORTREG = Exports the registry");
        }


    }
    }